import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/table';

export const columns: BasicColumn[] = [
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 150,
  },
  {
    title: '手机号',
    dataIndex: 'mobile',
    width: 120,
  },
  {
    title: '证件号',
    dataIndex: 'identityNo',
    width: 150,
  },
  {
    title: '标记人',
    dataIndex: 'addUserName',
    width: 120,
  },
  {
    title: '来源',
    dataIndex: 'sourceType',
    width: 120,
    customRender: ({ record }: Recordable) => {
      const sourceTypeArray = [
        { label: '销售新增', value: 1 },
        { label: '后台新增', value: 2 },
      ];
      const sourceType: any = sourceTypeArray.find((item) => item.value == record.sourceType);
      if (sourceType) {
        return sourceType.label;
      }
      return '';
    },
  },
  {
    title: '是否启用',
    dataIndex: 'isEnable',
    width: 120,
    customRender: ({ record }: Recordable) => {
      const isEnableArray = [
        { label: '不启用', value: 0 },
        { label: '启用', value: 1 },
      ];
      const isEnable: any = isEnableArray.find((item) => item.value == record.isEnable);
      if (isEnable) {
        return isEnable.label;
      }
      return '';
    },
  },
  {
    title: '描述',
    dataIndex: 'blackDesc',
    width: 200,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'mobile',
    label: '手机号',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'identityNo',
    label: '证件号',
    component: 'Input',
    colProps: { span: 5 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: 'Id',
    field: 'blacklistId',
    component: 'Input',
    required: false,
    show: false,
  },
  {
    label: '来源',
    field: 'sourceType',
    component: 'Input',
    required: false,
    defaultValue: 2,
    show: false,
  },
  {
    label: '手机号',
    field: 'mobile',
    component: 'Input',
    rules: [
      { required: true, message: '请输入手机号' },
      { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式错误！' },
    ],
  },
  {
    label: '证件号',
    field: 'identityNo',
    component: 'Input',
    required: true,
  },
  {
    label: '来源',
    field: 'sourceType',
    component: 'Input',
    required: true,
  },
  {
    field: 'isEnable',
    label: '是否启用',
    component: 'RadioButtonGroup',
    defaultValue: 0,
    componentProps: {
      options: [
        { label: '启用', value: 0 },
        { label: '禁用', value: 1 },
      ],
    },
  },
  {
    label: '描述',
    field: 'blackDesc',
    component: 'InputTextArea',
    required: false,
  },
];
